<!-- 跨越请求 -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="/public/jquery-1.8.3.min.js"> </script>
    <style>
        iframe {
            width: 100%;
            height: 500px;
            border: 1px solid #000;
        }
    </style>
<body>
<h2>测试iframe 跨域 </h2>
<script>
    // 每隔1秒刷新 iframe 内容
    setInterval(() => {
        var iframe = document.getElementById('targetIframe');
        var url = 'http://localhost:8081/customer-service/get-product?productInfo=productId%3D7466&type=3&timestamp=1762946745545&hashCode=6ec60b38ff752bf9a8200724d016d7aa&companyId=80028951&shopId=jyshop';
        // 方式1：重新设置 src 刷新（可带新参数）
        //iframe.src = url; // 可更新 URL 参数

        // 方式2：直接刷新 iframe  浏览器判断为跨域请求，报js错误, 不能请求远程
        //iframe.contentWindow.location.reload();
        //可以在控制台查看error: Uncaught SecurityError: Failed to read a named property 'reload' from 'Location': Blocked a frame with origin "http://localhost" from accessing a cross-origin frame.

        // 方式3：使用 window.location.href 跳转（不可带新参数）
        iframe.contentWindow.location.href = "http://localhost:8081/customer-service/get-product?productInfo=productId%3D7466&type=3&timestamp=1762946745545&hashCode=6ec60b38ff752bf9a8200724d016d7aa&companyId=80028951&shopId=jyshop";
    }, 1000);

</script>

<h1>iframe 跨域请求</h1>
<!--<iframe src="https://cn-uat-wxmall.dreame.tech/customer-service/get-product?productInfo=productId%3D7466&type=3&timestamp=1762946745545&hashCode=6ec60b38ff752bf9a8200724d016d7aa&companyId=80028951&shopId=jyshop">-->
<iframe id="targetIframe"  src="http://localhost:8081/customer-service/get-product?productInfo=productId%3D7466&type=3&timestamp=1762946745545&hashCode=6ec60b38ff752bf9a8200724d016d7aa&companyId=80028951&shopId=jyshop">
</iframe>
</body>
</html>